<template>
    <div>
      <h1>房间信息录入</h1>
      <a href="/AddView">房间信息添加</a>
      <br>
      房号：  <select v-model="find.roomid">
                        <option value="0">请选择</option>
                        <option v-for="b in swery" :value="b.roomid">{{ b.name }}</option>
                       </select>
      房型：  <select v-model="find.roomtypeid">
                        <option value="0">请选择</option>
                        <option v-for="a in swert" :value="a.roomtypeId">{{a.name  }}</option>
                       </select>
      <input type="button" value="查询" @click="Show">
      <table class="table">
        <thead>
            <tr>
                <td>房间名称</td>
                <td>类型</td>
                <td>房好</td>
                <td>地址</td>
                <td>电话</td>
                 <td>操作</td>
            </tr>
        </thead>
        <tbody>
            <tr v-for="c in data">
                 <td>{{c.name  }}</td>
                <td>{{c.typeName  }}</td>
                <td>{{c.roomName  }}</td>
                <td>{{ c.addr }}</td>
                <td>{{c.phone  }}</td>
                 <td><input type="button" value="编辑" @click="UptRoom(c.id)"></td>
            </tr>
        </tbody>
      </table>
    </div>
</template>

<script setup lang="ts">
import {ref,onMounted} from "vue"
import axios from "axios";
import { useRouter } from "vue-router";
const router=useRouter()
const UptRoom=(id:any)=>{
    router.push({path:"/UptView",query:{id:id}})
}
const data=ref([{
     "id": 2,
    "name": "上天入职",
    "roomid": 1,
    "roomtypeId": 1,
    "addr": "北京市",
    "phone": "16552444354",
    "typeName": "单人房",
    "roomName": "1001"
}])
onMounted(()=>{
    Show()
})
const Show=()=>{
    axios.get("https://localhost:7102/api/Room/GetRoom",{params:find.value}).then(res=>{
        data.value=res.data
    })
}
const find=ref({
    roomid:0,
    roomtypeid:0
})
onMounted(()=>{
    XIala()
    Xialak()
})
const swert=ref([{
    "roomtypeId": 0,
    "name": "string"
}])
const XIala=()=>{
    axios.get("https://localhost:7102/api/Room/Xiala").then(res=>{
        swert.value=res.data
    })
}
const swery=ref([{
  "roomid": 0,
    "name": "string"
}])
const Xialak=()=>{
    axios.get("https://localhost:7102/api/Room/Xialak").then(res=>{
        swery.value=res.data
    })
}
</script>

<style scoped>

</style>